package com.sise.aio和bio和nio.bio.bio2;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * @author idea
 * @data 2019/1/20
 */
public class Client {

    private static Integer port = 1001;

    private static BufferedReader bufferedReader = null;

    private static PrintWriter printWriter = null;

    public static void main(String[] args)  {
        try {
            Socket socket = new Socket();
            socket.connect(new InetSocketAddress("127.0.0.1", port));
            bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            printWriter = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
            printWriter.println("client is here!");
            printWriter.flush();
            String result = bufferedReader.readLine();
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
